#include "cmsis_os2.h"
#include <unistd.h>
#include <stdio.h>
#include "wifi_util.h"
#include "mqtt_util.h"

static void publish_thread(void *arg){
    (void)arg;
    connect_wifi();
    sleep(1);
    mqtt_connect();
}

void publish_task(void){
    osThreadAttr_t attr;
    attr.name = "publish_task";
    attr.attr_bits = 0U;
    attr.cb_mem = NULL;
    attr.cb_size = 0U;
    attr.stack_mem = NULL;
    attr.stack_size = 4096;
    attr.priority = 36;

    if (osThreadNew((osThreadFunc_t)publish_thread,NULL,&attr)==NULL)
    {
        printf("publish task failed\n");
    }
    
}